/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Beans;

import SessionBean.logicaLocal;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author Felipe
 */
public class Vaca {
    logicaLocal logica = lookuplogicaLocal();
    String codigo;

    public String getCodigo() {
        return codigo;
    }

    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }
    public String getGuardar(){
        if(codigo.length() == 6){
        logica.insertarVaca(codigo);
        return "Su vaca ha sido creada satisfactoriamente con el codigo" + codigo;
        }else{
           return "su vaca no ha podido crearse por que el codigo no cumple con las especificaciones" ;
        }
    }

    private logicaLocal lookuplogicaLocal() {
        try {
            Context c = new InitialContext();
            return (logicaLocal) c.lookup("java:global/Vacas/Vacas-ejb/logica!SessionBean.logicaLocal");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }
   
    
}
